package com.gxc.service.impl;

import com.gxc.dao.UserDao;
import com.gxc.dao.impl.UserDaoImpl;
import com.gxc.pojo.User;
import com.gxc.service.UserService;

/**
 * @Classname UserServiceImpl
 * @Description TODO
 * @Date 2020/11/16 8:25
 * @author by 97830
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    @Override
    public void registerUser(User user) {
        userDao.addUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
    }

    @Override
    public boolean existsUser(String username) {
        if (userDao.queryUserByUsername(username) == null){
            //等于null，说明没查到，表示可用
            return false;
        }
        return true;
    }
}